from duetopia.register.fields import *
from django import newforms as forms
from duetopia.register.models.meta import Keyword, Agent
from duetopia.register.models.dataset import DataSet, DataFormat

#from duetopia.register.models.time import Timespan

class DatasetShortForm(forms.Form):
    title = forms.CharField()
    keywords = KeywordSearchForm(Keyword.objects.filter())
    #abstract = forms.CharField(widget=forms.Textarea)

# django failed me, and is overcomplex :(
#class FormatChoices:
#    def __iter__(self):
#        formats = DataFormat.objects.filter()
#        yield (None,'------')
#        for f in formats:
#            yield (f.id,f.name+' ('+f.mimetype+')')

#class DataSourceForm(forms.Form):
#    uri = forms.CharField()
#    format = forms.ChoiceField(choices=FormatChoices())
## below is unused now

class DatasetContactForm(forms.Form):
    
    contacts = AgentSearchForm(Agent.objects.filter(),widget=AgentMultipleWidget)

class DatasetTextForm(forms.Form):
    keywords = KeywordSearchForm(Keyword.objects.filter())
    abstract = forms.CharField(widget=forms.Textarea)

#class DatasetTimeForm(form.Form):
#    published = TimespanSearchForm()

class DatasetExtentsForm(forms.Form):
    # generate form, but custom logic to convert these to geometry object
    west = forms.CharField(max_length=6)
    south = forms.CharField(max_length=6)
    east = forms.CharField(max_length=6)
    north = forms.CharField(max_length=6)

    
  
